package com.bit.aop.proxy;

//import net.sf.cglib.proxy.MethodInterceptor;
//import net.sf.cglib.proxy.MethodProxy;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CglibMethodInteceptor implements MethodInterceptor {
    private Object target;

    public CglibMethodInteceptor(Object target) {
        this.target = target;
    }

    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("我是中介, 我开始代理");
        Object invoke = method.invoke(target, objects);
        System.out.println("我是中介, 我结束代理");
        return invoke;
    }
}
